module Oos4ruby
  class UnknownUser < ArgumentError; end
  
  AtomNamespace = 'http://www.w3.org/2005/Atom'
  AppNamespace = 'http://www.w3.org/2007/app'
  OosNamespace = 'http://11870.com/api/oos'  
  XhtmlNamespace = 'http://www.w3.org/1999/xhtml'
  GeoRSSNamespace = 'http://www.georss.org/georss/10'
  GmlNamespace = 'http://www.opengis.net/gml'
  OsNamespace = 'http://a9.com/-/spec/opensearch/1.1/'
  XmlNamespaces = {
    'app' => AppNamespace,
    'atom' =>  AtomNamespace,    
    'xhtml' => XhtmlNamespace,
    'oos' => OosNamespace,
    'georss' => GeoRSSNamespace,
    'gml' => GmlNamespace,
    'os' => OsNamespace
  }
  
  AtomEntryContentType = 'application/atom+xml;type=entry'
  
  OOS_URL = 'http://11870.com'
  API_URL = OOS_URL + '/api/v1'
  
  SITES_URL = Oos4ruby::API_URL + '/sites'
  CONTACTS_URL = Oos4ruby::API_URL + '/contacts'
  USERS_URL = Oos4ruby::API_URL + '/users'
  TAGS_URL = API_URL + '/tags'
  LISTS_URL = API_URL + '/lists'
  PRIVACY_URL = API_URL + '/privacy'
  TRUSTED_URL = API_URL + '/trusted'
  SEARCH_URL = API_URL + '/search'
end
%w(rubygems).each { |f| require f }

require 'oos4ruby/http_invoker.rb'
require 'oos4ruby/auth.rb'
require 'oos4ruby/bean.rb'
require 'oos4ruby/category.rb'
require 'oos4ruby/collection.rb'
require 'oos4ruby/contact.rb'
require 'oos4ruby/contacts.rb'
require 'oos4ruby/entry.rb'
require 'oos4ruby/feed.rb'
require 'oos4ruby/media.rb'
require 'oos4ruby/medias.rb'
require 'oos4ruby/oos.rb'
require 'oos4ruby/search.rb'
require 'oos4ruby/service.rb'
require 'oos4ruby/site.rb'
require 'oos4ruby/sites.rb'
require 'oos4ruby/user.rb'
require 'oos4ruby/version.rb'


class String #:nodoc:
  def underscore
     self.to_s.gsub(/::/, '/').
     gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
     gsub(/([a-z\d])([A-Z])/,'\1_\2').
     tr("-", "_").
     downcase
  end
end

require 'rexml/element'
module REXML #:nodoc:
class REXML::Element #:nodoc:
  def add_category(term, scheme = nil, label = nil)
    c = REXML::Element.new('category', self)
    c.add_attribute('term', term)
    c.add_attribute('scheme', scheme) if scheme
    c.add_attribute('label', label) if label
    c
  end
end
end
